﻿
namespace ZquenceStudio3Host.DspPlugins.Synthesizers.Nodesizer.Engine.Modules.Protected
{
    [ModuleDisplay("Out")]
    internal class OutModule : BaseModule
    {
        private double[] mDummyBuffer;

        internal ModuleInput Left;
        internal ModuleInput Right;

        public OutModule( ModuleManager manager)
            : base(manager)
        {
            // TODO: Make better for better memory performance?
            mDummyBuffer = new double[manager.SoundEngineContext.BufferSize];

            AddInput(Left = new ModuleInput("Left", IOType.Audio, this));
            AddInput(Right = new ModuleInput("Right", IOType.Audio, this));
        }
        
        /// <summary>
        /// Get processed left output.
        /// </summary>
        public double[] ProcessedLeft
        {
            get
            {
                // TODO: Make better for better memory performance?
                if (Left.FromOutput == null)
                {
                    return mDummyBuffer;
                }
                return Left.FromOutput.AudioBuffer.Buffer;
            }
        }

        /// <summary>
        /// Get processed right output.
        /// </summary>
        public double[] ProcessedRight
        {
            get
            {
                // TODO: Make better for better memory performance?
                if (Right.FromOutput == null)
                {
                    return mDummyBuffer;
                }
                return Right.FromOutput.AudioBuffer.Buffer;
            }
        }

        public override void Process()
        {

        }
    }
}
